//
//  BannerView.m
//  DMT_Print
//
//  Created by 牛魔王 on 2018/9/3.
//  Copyright © 2018年 JING. All rights reserved.
//

#import "BannerView.h"

@implementation BannerView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:_banner];
    }
    return self;
}

- (void)bannerBegin {
    _banner=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, 190)];
    _banner.pagingEnabled=YES;
    UIImage *bannerImage=[UIImage imageNamed:@"zhen"];
    _bnm=[[UIImageView alloc]initWithImage:bannerImage];
    _bnm.frame=CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width, 190);
    [_banner addSubview:_bnm];
    UIImage *bannerImage2=[UIImage imageNamed:@"zhen"];
    _bnm2=[[UIImageView alloc]initWithImage:bannerImage2];
    _bnm2.frame=CGRectMake(_banner.bounds.size.width, 0,[UIScreen mainScreen].bounds.size.width, 190);
    [_banner addSubview:_bnm2];
    UIImage *bannerImage3=[UIImage imageNamed:@"zhen"];
    _bnm3=[[UIImageView alloc]initWithImage:bannerImage3];
    _bnm3.frame=CGRectMake(_banner.bounds.size.width*2, 0,[UIScreen mainScreen].bounds.size.width, 190);
    [_banner addSubview:_bnm3];
    CGRect bnr = _banner.bounds;
    CGRect bnr2 = bnr;
    bnr2.size.width*=3.0;
    _banner.contentSize=bnr2.size;
    _banner.bounces=NO;
    _banner.showsVerticalScrollIndicator=NO;
    _banner.showsHorizontalScrollIndicator=NO;
    
    self.myPageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 200, CGRectGetWidth(self.frame), 50)];
    self.myPageControl.numberOfPages = 2;
    self.myPageControl.currentPage = 0;
    [self addSubview:_banner];
    [self addSubview:self.myPageControl];
    self.timer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeView) userInfo:nil repeats:YES];
    _banner.tag=1000;
}

- (void)changeView {
    if (self.ChangeView) {
        self.ChangeView();
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
